<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set the timezone used by this calendar</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intlcalendar.settime.html">« IntlCalendar::setTime</a></li>
      <li style="float: right;"><a href="intlcalendar.todatetime.html">IntlCalendar::toDateTime »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intlcalendar.html">IntlCalendar</a></li>
    <li>Set the timezone used by this calendar</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intlcalendar.settimezone" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlCalendar::setTimeZone</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8, PECL &gt;= 3.0.0a1)</p><p class="refpurpose"><span class="refname">IntlCalendar::setTimeZone</span> &mdash; <span class="dc-title">Set the timezone used by this calendar</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlcalendar.settimezone-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>IntlCalendar::setTimeZone</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="class.intltimezone.html" class="type IntlTimeZone">IntlTimeZone</a></span>|<span class="type"><a href="class.datetimezone.html" class="type DateTimeZone">DateTimeZone</a></span>|<span class="type">string</span>|<span class="type">null</span></span> <code class="parameter">$timezone</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>intlcal_set_time_zone</strong></span>(<span class="methodparam"><span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <code class="parameter">$calendar</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="class.intltimezone.html" class="type IntlTimeZone">IntlTimeZone</a></span>|<span class="type"><a href="class.datetimezone.html" class="type DateTimeZone">DateTimeZone</a></span>|<span class="type">string</span>|<span class="type">null</span></span> <code class="parameter">$timezone</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Defines a new timezone for this calendar. The time represented by the
   object is preserved to the detriment of the field values.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlcalendar.settimezone-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">calendar</code></dt>

    <dd>

     <p class="para"><span class="classname"><a href="class.intlcalendar.html" class="classname">IntlCalendar</a></span> 实例。</p>
    </dd>

   
   
    <dt>
<code class="parameter">timezone</code></dt>

    <dd>

     <p class="para">
      The new timezone to be used by this calendar. It can be specified in the
      following ways:
      

<ul class="itemizedlist">
 <li class="listitem">
  <p class="para">
   <strong><code>null</code></strong>, in which case the default timezone will be used, as specified in
   the ini setting <a href="datetime.configuration.html#ini.date.timezone" class="link">date.timezone</a> or
   through the function <span class="function"><a href="function.date-default-timezone-set.html" class="function">date_default_timezone_set()</a></span> and as
   returned by <span class="function"><a href="function.date-default-timezone-get.html" class="function">date_default_timezone_get()</a></span>.
  </p>
 </li>
 <li class="listitem">
  <p class="para">
   An <span class="classname"><a href="class.intltimezone.html" class="classname">IntlTimeZone</a></span>, which will be used directly.
  </p>
 </li>
 <li class="listitem">
  <p class="para">
   A <span class="classname"><a href="class.datetimezone.html" class="classname">DateTimeZone</a></span>. Its identifier will be extracted
   and an ICU timezone object will be created; the timezone will be backed
   by ICUʼs database, not PHPʼs.
  </p>
 </li>
 <li class="listitem">
  <p class="para">
   A <span class="type">string</span>, which should be a valid ICU timezone identifier.
   See <span class="function"><a href="intltimezone.createtimezoneidenumeration.html" class="function">IntlTimeZone::createTimeZoneIDEnumeration()</a></span>. Raw
   offsets such as <code class="literal">&quot;GMT+08:30&quot;</code> are also accepted.
  </p>
 </li>
</ul>

     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlcalendar.settimezone-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>true</code></strong> on success and <strong><code>false</code></strong> on failure.
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-intlcalendar.settimezone-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2418">
   <p><strong>示例 #1 <span class="function"><strong>IntlCalendar::setTimeZone()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Europe/Lisbon'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'intl.default_locale'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'es_ES'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$cal&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlGregorianCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">2013</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5&nbsp;</span><span style="color: #FF8000">/*&nbsp;May&nbsp;*/</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">12</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"(instant&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTime</span><span style="color: #007700">()}</span><span style="color: #DD0000">)\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setTimeZone</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">getGMT</span><span style="color: #007700">());<br />echo&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"(instant&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTime</span><span style="color: #007700">()}</span><span style="color: #DD0000">)\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setTimeZone</span><span style="color: #007700">(</span><span style="color: #DD0000">'GMT+03:33'</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"(instant&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTime</span><span style="color: #007700">()}</span><span style="color: #DD0000">)\n"</span><span style="color: #007700">;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
sábado, 1 de junio de 2013 12:00:00 Hora de verano de Europa occidental
(instant 1370084400000)
sábado, 1 de junio de 2013 11:00:00 GMT
(instant 1370084400000)
sábado, 1 de junio de 2013 14:33:00 GMT+03:33
(instant 1370084400000)
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>